-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Use geteuid() instead of getuid() to check privilege #3364
Conversation
Hi @ruihe774. Thanks for your PR. I'm waiting for a ostreedev member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct to me, I tend to favour geteuid over getuid, most of the time that's what people actually want to do. But I'm not sure about every little use-case of OSTree.
What I will say, was there actually a bug or defect found here, etc.?
Or are we just changing for the sake of it because geteuid is the "better" one that's a more true test of rootness?
Not appeared. But it is easy to produce one. You can set the SUID bit of a program using libostree (e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No one should be including libostree in a setuid binary.
(Really there should be no setuid binaries at all, but that's another thing)
/ok-to-test |
Yes. However, processes can drop privileges temporarily using |
Yeah, though that kind of thing I personally consider a bad idea because most modern codebases are multithreaded, and changing uid affects all threads, which can have surprising effects. Basically if you do this type of thing you should fork off a dedicated helper process which runs always as that uid from the start - and that process shouldn't be doing anything related to ostree in general. |
/override continuous-integration/jenkins/pr-merge |
@cgwalters: Overrode contexts on behalf of cgwalters: continuous-integration/jenkins/pr-merge In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This is implemented by libc (e.g. NPTL). If you use raw syscall (sounds tricky), changing uid affects only current thread. |
Yes, but doing raw syscalls like that last I heard from the glibc developers often means you cannot invoke any later APIs from glibc, which becomes a giant pain in the butt. I'm not sure if there's a better reference but (searches for a minute) yeah see this comment for example. |
I believe the correct way is to check
geteuid() == 0
, notgetuid() == 0
.